//
//  WBNetworkManager+Extension.swift
//  Inpro
//
//  Created by 彭灿 on 16/10/8.
//  Copyright © 2016年 Roble. All rights reserved.
//

import Foundation

extension WBNetworkManager {
    
    func statusList(since_id: Int64 = 0 , max_id: Int64 = 0,competion: @escaping (_ list: [[String: Any]]?, _ isSuccess: Bool)->()) {
        // 用 网络工具 加载网络数据
        
        let urlString = "https://api.weibo.com/2/statuses/home_timeline.json"
        let params = ["access_token": "2.00st_RECxQ4YfD7e0f61b22bbUaDaC", "since_id": "\(since_id)","max_id": "\(max_id > 0 ? max_id - 1 : 0)"]
        
        request(URLString: urlString, parameters: params) {(json, isSuccess) in
            // 解包 json
            let result = json as? [String: Any]
            if result != nil {
                // 从json中获取 statuese 字典数据
                // 如果 as? 失败，result = nil
                let resultPush = result?["statuses"] as? [[String: Any]]
                competion(resultPush, isSuccess)
            }
            
        }
    }
    
    // 返回微博信息未读数量
//    func unreadCount(completion: (_ count: Int)->()) {
    func unreadCount(count: Int = 9) {
        let urlString = "api url"
        print("请求中\(urlString) , 有 \(count) 未读数据")
        
    }
}
